package com.artPreter.controller;



import com.artPreter.pojo.ArtType;
import com.artPreter.pojo.Result;

import com.artPreter.service.IArtTypeService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 艺术分类表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-11-25
 */
@RestController
@RequestMapping("/artType")
public class ArtTypeController {


    @Autowired
    private IArtTypeService artTypeService;

    /**
     * 板块分类分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody ArtType artType) {
        IPage<ArtType> artTypeIPage = artTypeService.getPage(currentPage, size, artType);
        return Result.success(artTypeIPage);
    }

    /**
     *  添加板块分类
     * @param artType
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody ArtType artType) {
        artTypeService.add(artType);
        return Result.success();
    }

    /**
     *  修改板块分类
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody ArtType artType) {
        artTypeService.edit(artType);
        return Result.success();
    }

    /**
     * 删除板块分类
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody ArtType artType){
        artTypeService.delete(artType);
        return Result.success();
    }

    /**
     * 获取板块分类列表
     * @param
     * @return
     */
    @PostMapping("/getList")
    public Result getList(@RequestBody ArtType artType){
        List<ArtType> result = artTypeService.getList(artType);
        return Result.success(result);
    }

}
